//
//  LeverageTradeButton.m
//  XTXOneToOne
//
//  Created by Canny on 2018/10/29.
//  Copyright © 2018年 WK. All rights reserved.
//

#import "LeverageTradeButton.h"
@interface LeverageTradeButton ()


@end

@implementation LeverageTradeButton
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    self.backgroundColor=RGB(255,255,255);
    CGFloat W1 = 30 ,W2 = (G_SCREENWIDTH/2.0-30)/2.0,W3 = (G_SCREENWIDTH/2.0-30)/2.0;

    UILabel * lab1 = [[UILabel alloc]init];
    [self addSubview:lab1];
//    lab1.backgroundColor =[UIColor orangeColor];
    lab1.text=@"0";
    lab1.textColor=RGB(140, 159, 173);
    lab1.font=[UIFont systemFontOfSize:11];
    lab1.textAlignment = NSTextAlignmentLeft;
    _lab1=lab1;
    [lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self.mas_left).offset(0);
        make.width.mas_equalTo(W1);
    }];
    _lab1=lab1;
    
    UILabel * lab2 = [[UILabel alloc]init];
//    lab2.backgroundColor =[UIColor cyanColor];

    [self addSubview:lab2];
    lab2.text=@"0";
    lab2.textColor=RGB(140, 159, 173);
    lab2.font=[UIFont systemFontOfSize:11];
    _lab2=lab2;
    lab2.textAlignment = NSTextAlignmentCenter;
    [lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self.mas_left).offset(W1);
        make.width.mas_equalTo(W2);
    }];
    
    UILabel * lab3 = [[UILabel alloc]init];
//    lab3.backgroundColor =[UIColor blueColor];

    [self addSubview:lab3];
    lab3.text=@"0";
    lab3.textColor=RGB(140, 159, 173);
    lab3.font=[UIFont systemFontOfSize:11];
    lab3.textAlignment = NSTextAlignmentCenter;
    _lab3=lab3;
    [lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.right.equalTo(self.mas_right).offset(-10);
        make.width.mas_equalTo(W3-10);
    }];
    
   
}

-(void)click{
    if (self.Type == LeverageTradeButtonType_Buy) {
        self.backgroundColor = RGB(184, 253, 213);
    }else if (self.Type == LeverageTradeButtonType_Sale){
        self.backgroundColor = RGB(255, 214, 200);
    }
    [self performSelector:@selector(refreashColor) withObject:nil afterDelay:0.5];

}

-(void)setDataSource:(LTradeModel *)dataSource{
    _dataSource= dataSource;
    _lab2.text=[NSString stringWithFormat:@"%@",dataSource.price];
    _lab3.text=[NSString stringWithFormat:@"%@",dataSource.amount];

}

-(void)refreashColor{
    self.backgroundColor= [UIColor whiteColor];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
